import sys
import numpy as np

sys.path.append("../utils")

from utils import OpRunner, compare, verify_result
import time
import tensorflow as tf

def main():
    func = OpRunner("./build/libop.so", 3, pint_time=True)
    minvalue = 1
    maxvalue = 100
    shape = [10 * 1024 * 1024]
    # for dtype in [np.float16, np.float32, np.int32, np.int8]:
    for dtype in [np.float16, np.float32, np.int32]:
        print("测试类型", dtype)
        x1 = np.random.uniform(minvalue, maxvalue, shape).astype(dtype)
        x2 = np.random.uniform(minvalue, maxvalue, shape).astype(dtype)
        output = np.ones(shape, dtype=np.bool_)
        func([x1, x2, output], [2])
        # real_result = np.less_equal(x1, x2)
        real_result = tf.math.greater_equal(x1, x2).numpy()
        print("output", output[:10])
        print("golden", real_result[:10])
        # print(real_result)
        # if compare(output, real_result):
        #     print(f"{dtype}成功")
        # verify_result(output, real_result)
        print("结果", (output == real_result).all())
        print("----------------------------")


if __name__ == "__main__":
    main()
